//
// Created by zhouwd on 2019/7/30.
//

#include "media_video_frame_notify.h"




int _MEDIA_VIDEO_FRAME_NOTIFY::init(JavaVM *javaVM, jobject callbackObj, jmethodID onChangedMD) {
    this->javaVM = javaVM;
    this->callbackObj = callbackObj;
    this->onChangedMD = onChangedMD;
    return 0;
}

int _MEDIA_VIDEO_FRAME_NOTIFY::destory() {



    return 0;
}

void _MEDIA_VIDEO_FRAME_NOTIFY::updateFrame() {
    ALOGE("_MEDIA_VIDEO_FRAME_NOTIFY > updateFrame > %p > callbackObj > %p > onChangedMD > %p", java, callbackObj, onChangedMD);
    if (java != nullptr) {
        java->CallVoidMethod(callbackObj, onChangedMD);

    } else {
        ALOGE("_MEDIA_VIDEO_FRAME_NOTIFY > updateFrame > null");
    }

}

int _MEDIA_VIDEO_FRAME_NOTIFY::prepare() {
    ALOGE("_MEDIA_VIDEO_FRAME_NOTIFY > prepare");
    if (javaVM)
    {

        int getEnvStat = javaVM->GetEnv((void **)&java, JNI_VERSION_1_6);
        ALOGE("_MEDIA_VIDEO_FRAME_NOTIFY > init > getEnvStat > %d", getEnvStat);
        if (getEnvStat == JNI_EDETACHED)
        {
            JavaVMAttachArgs args = { JNI_VERSION_1_6, 0, 0 };
            javaVM->AttachCurrentThread(&java, &args);
        }
        else if (getEnvStat == JNI_EVERSION)
        {

        }
    }

    return 0;
}


